package com.itlong.cloud.resource;

import com.itlong.cloud.POJO.PO.DeviceEntranceInfoPO;
import com.itlong.cloud.commons.service.ICloudDeviceOnlineService;
import com.itlong.cloud.iottp.IIotDeviceOnlineServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <desc>
 *      访客人脸接口暴露。
 * <desc/>
 *
 * @createDate 2019/03/04.
 */
@RestController
public class IotDeviceOnlineServiceResource implements IIotDeviceOnlineServiceClient {

    @Autowired
    private ICloudDeviceOnlineService iCloudDeviceOnlineService;

    /**
     * <desc>
     *      维护在线设备缓存
     * <desc/>
     *
     * @return
     * @author Qiang.S
     * @createDate 2019/07/03
     */
    @Override
    @RequestMapping(path = "/iotTp/online/timeTaskMaintenanceOnline",method = RequestMethod.POST)
    public void timeTaskMaintenanceOnline() {
        iCloudDeviceOnlineService.timeTaskMaintenanceOnline();
    }

    /**
     * <desc>
     *      根据设备编号查询本组所有设备
     * <desc/>
     *
     * @return
     * @author Qiang.S
     * @createDate 2020/02/25
     */
    @Override
    @RequestMapping(path = "/iotTp/online/getAllDoorByDeviceUnique",method = RequestMethod.POST)
    public List<DeviceEntranceInfoPO> getAllDoorByDeviceUnique(@RequestParam("deviceUnique") String deviceUnique) {
        return iCloudDeviceOnlineService.getAllDoorByDeviceUnique(deviceUnique);
    }

    /**
     * <desc>
     *      根据设备编号查询没有创建主门禁的设备编号
     * <desc/>
     *
     * @return
     * @author Qiang.S
     * @createDate 2020/02/25
     */
    @Override
    @RequestMapping(path = "/iotTp/online/getDoorByGroup",method = RequestMethod.POST)
    public List<DeviceEntranceInfoPO> getDoorByGroup(@RequestParam("deviceUnique") String deviceUnique) {
        return iCloudDeviceOnlineService.getDoorByGroup(deviceUnique);
    }

    /**
     * <desc>
     *      获取京东设备id
     * </desc>
     *
     * @param deviceUnique
     * @param deviceType
     * @return
     * @author Jiaqi.X
     * @createDate 2020/08/11
     */
    @Override
    @RequestMapping(path = "/iotTp/online/getJdDeviceId",method = RequestMethod.POST)
    public String getJdDeviceId(@RequestParam("deviceUnique") String deviceUnique,@RequestParam("deviceType") Integer deviceType){
        return iCloudDeviceOnlineService.getJdDeviceId(deviceUnique,deviceType);
    }

    /**
     * <desc>
     * 维护在线设备缓存
     * <desc/>
     *
     * @return
     * @author caoshuai
     * @createDate 2020/09/25
     */
    @Override
    @RequestMapping(path = "/iotTp/online/timeTaskHWMaintenanceOnline",method = RequestMethod.POST)
    public void timeTaskHWMaintenanceOnline() {
        iCloudDeviceOnlineService.timeTaskHWMaintenanceOnline();

    }
}
